

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>mindspore.Parameter &mdash; MindSpore master documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="mindspore.ParameterTuple" href="mindspore.ParameterTuple.html" />
    <link rel="prev" title="mindspore.SparseTensor" href="mindspore.SparseTensor.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> MindSpore
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">MindSpore Python API</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="../mindspore.html">mindspore</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id1">张量</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../mindspore.html#id2">参数</a><ul class="current">
<li class="toctree-l3 current"><a class="current reference internal" href="#">mindspore.Parameter</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.ParameterTuple.html">mindspore.ParameterTuple</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id3">数据类型</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id4">随机种子</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id5">模型</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id6">数据处理工具</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id7">混合精度管理</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id8">序列化</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id9">即时编译</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id10">日志</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id11">自动混合精度</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id12">安装验证</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id13">调试</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.html#id14">内存回收</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.common.initializer.html">mindspore.common.initializer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.communication.html">mindspore.communication</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.compression.html">mindspore.compression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.context.html">mindspore.context</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.html">mindspore.dataset</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.audio.html">mindspore.dataset.audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.config.html">mindspore.dataset.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.text.html">mindspore.dataset.text</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.transforms.html">mindspore.dataset.transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.vision.html">mindspore.dataset.vision</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.mindrecord.html">mindspore.mindrecord</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.html">mindspore.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.probability.html">mindspore.nn.probability</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.transformer.html">mindspore.nn.transformer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.numpy.html">mindspore.numpy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.ops.html">mindspore.ops</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.html">mindspore.parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.nn.html">mindspore.parallel.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.profiler.html">mindspore.profiler</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.scipy.html">mindspore.scipy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.train.html">mindspore.train</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.boost.html">mindspore.boost</a></li>
</ul>
<p class="caption"><span class="caption-text">MindSpore C++ API</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://www.mindspore.cn/lite/api/zh-CN/master/api_cpp/mindspore.html">MindSpore Lite↗</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">MindSpore</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../mindspore.html">mindspore</a> &raquo;</li>
        
      <li>mindspore.Parameter</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/api_python/mindspore/mindspore.Parameter.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="mindspore-parameter">
<h1>mindspore.Parameter<a class="headerlink" href="#mindspore-parameter" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="mindspore.Parameter">
<em class="property">class </em><code class="sig-prename descclassname">mindspore.</code><code class="sig-name descname">Parameter</code><span class="sig-paren">(</span><em class="sig-param">default_input</em>, <em class="sig-param">name=None</em>, <em class="sig-param">requires_grad=True</em>, <em class="sig-param">layerwise_parallel=False</em>, <em class="sig-param">parallel_optimizer=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.Parameter" title="Permalink to this definition">¶</a></dt>
<dd><p><cite>Parameter</cite> 是 <cite>Tensor</cite> 的子类，当它们被绑定为Cell的属性时，会自动添加到其参数列表中，并且可以通过Cell的某些方法获取，例如 <cite>cell.get_parameters()</cite> 。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>在”semi_auto_parallel”和”auto_parallel”的并行模式下，如果使用 <cite>Initializer</cite> 模块初始化参数，参数的类型将为 <cite>Tensor</cite> ，<a class="reference internal" href="../ops/mindspore.ops.AllGather.html#mindspore.ops.AllGather" title="mindspore.ops.AllGather"><code class="xref py py-class docutils literal notranslate"><span class="pre">mindspore.ops.AllGather</span></code></a> 。<cite>Tensor</cite> 仅保存张量的形状和类型信息，而不占用内存来保存实际数据。</p></li>
<li><p>并行场景下存在参数的形状发生变化的情况，用户可以调用 <cite>Parameter</cite> 的 <cite>init_data</cite> 方法得到原始数据。</p></li>
<li><p>如果网络中存在需要部分输入为 <cite>Parameter</cite> 的算子，则不允许这部分输入的 <cite>Parameter</cite> 进行转换。</p></li>
<li><p>如果在 <cite>Cell</cite> 里初始化一个 <cite>Parameter</cite> 作为 <cite>Cell</cite> 的属性时，建议使用默认值None，否则 <cite>Parameter</cite> 的 <cite>name</cite> 可能与预期不一致。</p></li>
</ul>
</div>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>default_input</strong> (Union[Tensor, int, float, numpy.ndarray, list]) - 初始化参数的输入值。</p></li>
<li><p><strong>name</strong> (str) - 参数的名称。默认值：None。</p></li>
<li><p><strong>requires_grad</strong> (bool) - 是否需要微分求梯度。默认值：True。</p></li>
<li><p><strong>layerwise_parallel</strong> (bool) - 在数据/混合并行模式下，<cite>layerwise_parallel</cite> 配置为True时，参数广播和梯度聚合时会过滤掉该参数。默认值：False。</p></li>
<li><p><strong>parallel_optimizer</strong> (bool) - 用于在 <cite>semi_auto_parallel</cite> 或 <cite>auto_parallel</cite> 并行模式下区分参数是否进行优化器切分。仅在 <cite>mindspore.context.set_auto_parallel_context()</cite> 并行配置模块中设置 <cite>enable_parallel_optimizer</cite> 启用优化器并行时有效。默认值：True。</p></li>
</ul>
<p><strong>样例：</strong></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">mindspore</span> <span class="kn">import</span> <span class="n">Parameter</span><span class="p">,</span> <span class="n">Tensor</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mindspore.ops</span> <span class="k">as</span> <span class="nn">ops</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mindspore.nn</span> <span class="k">as</span> <span class="nn">nn</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mindspore</span>
<span class="go">&gt;&gt;&gt;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">class</span> <span class="nc">Net</span><span class="p">(</span><span class="n">nn</span><span class="o">.</span><span class="n">Cell</span><span class="p">):</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="gp">... </span>        <span class="nb">super</span><span class="p">(</span><span class="n">Net</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">matmul</span> <span class="o">=</span> <span class="n">ops</span><span class="o">.</span><span class="n">MatMul</span><span class="p">()</span>
<span class="gp">... </span>        <span class="bp">self</span><span class="o">.</span><span class="n">weight</span> <span class="o">=</span> <span class="n">Parameter</span><span class="p">(</span><span class="n">Tensor</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> <span class="n">mindspore</span><span class="o">.</span><span class="n">float32</span><span class="p">),</span> <span class="n">name</span><span class="o">=</span><span class="s2">&quot;w&quot;</span><span class="p">,</span> <span class="n">requires_grad</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">... </span>    <span class="k">def</span> <span class="nf">construct</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
<span class="gp">... </span>        <span class="n">out</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">matmul</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">weight</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">... </span>        <span class="k">return</span> <span class="n">out</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">net</span> <span class="o">=</span> <span class="n">Net</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Tensor</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)),</span> <span class="n">mindspore</span><span class="o">.</span><span class="n">float32</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">net</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="go">[[2.]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">net</span><span class="o">.</span><span class="n">weight</span><span class="o">.</span><span class="n">set_data</span><span class="p">(</span><span class="n">Tensor</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)),</span> <span class="n">mindspore</span><span class="o">.</span><span class="n">float32</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">net</span><span class="p">(</span><span class="n">x</span><span class="p">))</span>
<span class="go">[[0.]]</span>
</pre></div>
</div>
<dl class="method">
<dt id="mindspore.Parameter.cache_enable">
<em class="property">property </em><code class="sig-name descname">cache_enable</code><a class="headerlink" href="#mindspore.Parameter.cache_enable" title="Permalink to this definition">¶</a></dt>
<dd><p>表示该参数是否开启缓存功能。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.cache_shape">
<em class="property">property </em><code class="sig-name descname">cache_shape</code><a class="headerlink" href="#mindspore.Parameter.cache_shape" title="Permalink to this definition">¶</a></dt>
<dd><p>如果使用缓存，则返回对应参数的缓存shape。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.clone">
<code class="sig-name descname">clone</code><span class="sig-paren">(</span><em class="sig-param">init='same'</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.Parameter.clone" title="Permalink to this definition">¶</a></dt>
<dd><p>克隆参数。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>init</strong> (Union[Tensor, str, numbers.Number]) - 初始化参数的形状和数据类型。如果 <cite>init</cite> 是 <cite>Tensor</cite> 或 <cite>numbers.Number</cite> ，则克隆一个具有相同数值、形状和数据类型的新参数。 如果 <cite>init</cite> 是 <cite>str</cite> ，则 <cite>init</cite> 将继承 <cite>Initializer</cite> 模块中对应的同名的类。例如，如果 <cite>init</cite> 是’same’，则克隆一个具有相同数据、形状和数据类型的新参数。默认值：’same’。</p></li>
</ul>
<p><strong>返回：</strong></p>
<p>Parameter，返回克隆的新参数。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.comm_fusion">
<em class="property">property </em><code class="sig-name descname">comm_fusion</code><a class="headerlink" href="#mindspore.Parameter.comm_fusion" title="Permalink to this definition">¶</a></dt>
<dd><p>获取此参数的通信算子的融合类型（int）。</p>
<p>在 <cite>AUTO_PARALLEL</cite> 和 <cite>SEMI_AUTO_PARALLEL</cite> 模式下，一些用于参数或梯度聚合的通信算子将自动插入。fusion的值必须大于等于0。当fusion的值为0时，算子不会融合在一起。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.data">
<em class="property">property </em><code class="sig-name descname">data</code><a class="headerlink" href="#mindspore.Parameter.data" title="Permalink to this definition">¶</a></dt>
<dd><p>返回参数对象。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.init_data">
<code class="sig-name descname">init_data</code><span class="sig-paren">(</span><em class="sig-param">layout=None</em>, <em class="sig-param">set_sliced=False</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.Parameter.init_data" title="Permalink to this definition">¶</a></dt>
<dd><p>初始化参数的数据。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>layout</strong> (Union[None, tuple]) - 参数的layout信息。layout[dev_mat, tensor_map, slice_shape, filed_size, uniform_split, opt_shard_group]：默认值：None。仅在 <cite>SEMI_AUTO_PARALLEL</cite> 或 <cite>AUTO_PARALLEL</cite> 模式下layout不是None。</p>
<ul>
<li><p><strong>dev_mat</strong> (list(int)) - 该参数的设备矩阵。</p></li>
<li><p><strong>tensor_map</strong> (list(int)) - 该参数的张量映射。</p></li>
<li><p><strong>slice_shape</strong> (list(int)) - 该参数的切片shape。</p></li>
<li><p><strong>filed_size</strong> (int) - 该权重的行数。</p></li>
<li><p><strong>uniform_split</strong> (bool) - 该参数是否进行均匀切分。</p></li>
<li><p><strong>opt_shard_group</strong> (str) - 该参数进行优化器切分时的group。</p></li>
</ul>
</li>
<li><p><strong>set_sliced</strong> (bool) - 参数初始化时被设定为分片，则为True。默认值：False。</p></li>
</ul>
<p><strong>返回：</strong></p>
<p>初始化数据后的 <cite>Parameter</cite> 。如果当前 <cite>Parameter</cite> 已初始化，则更新 <cite>Parameter</cite> 数据。</p>
<p><strong>异常：</strong></p>
<ul class="simple">
<li><p><strong>RuntimeError</strong> - 参数使用 <cite>Initializer</cite> 模块进行初始化，初始化后并行模式发生更改。</p></li>
<li><p><strong>ValueError</strong> - <cite>layout</cite> 长度小于6。</p></li>
<li><p><strong>TypeError</strong> - <cite>layout</cite> 不是元组。</p></li>
</ul>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.layerwise_parallel">
<em class="property">property </em><code class="sig-name descname">layerwise_parallel</code><a class="headerlink" href="#mindspore.Parameter.layerwise_parallel" title="Permalink to this definition">¶</a></dt>
<dd><p>获取此参数的逐层并行状态（bool）。</p>
<p>在 <cite>DATA_PARALLEL</cite> 和 <cite>HYBRID_PARALLEL</cite> 模式下，如果 <cite>layerwise_parallel</cite> 为True，则广播和gradients通信将不会应用到参数。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.name">
<em class="property">property </em><code class="sig-name descname">name</code><a class="headerlink" href="#mindspore.Parameter.name" title="Permalink to this definition">¶</a></dt>
<dd><p>获取参数的名称。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.parallel_optimizer">
<em class="property">property </em><code class="sig-name descname">parallel_optimizer</code><a class="headerlink" href="#mindspore.Parameter.parallel_optimizer" title="Permalink to this definition">¶</a></dt>
<dd><p>获取此参数的优化器并行状态（bool）。</p>
<p>用于在 <cite>AUTO_PARALLEL</cite> 和 <cite>SEMI_AUTO_PARALLEL</cite> 模式下过滤权重切分操作。当在 <cite>mindspore.context.set_auto_parallel_context()</cite> 中启用优化器并行时，它才有效。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.parallel_optimizer_comm_recompute">
<em class="property">property </em><code class="sig-name descname">parallel_optimizer_comm_recompute</code><a class="headerlink" href="#mindspore.Parameter.parallel_optimizer_comm_recompute" title="Permalink to this definition">¶</a></dt>
<dd><p>获取此参数的优化器并行通信重计算状态（bool）。</p>
<p>在 <cite>AUTO_PARALLEL</cite> 和 <cite>SEMI_AUTO_PARALLEL</cite> 模式下，当使用并行优化器时，会自动插入一些 <a class="reference internal" href="../ops/mindspore.ops.AllGather.html#mindspore.ops.AllGather" title="mindspore.ops.AllGather"><code class="xref py py-class docutils literal notranslate"><span class="pre">mindspore.ops.AllGather</span></code></a> 算子，用于参数聚合。它用于控制这些 <a class="reference internal" href="../ops/mindspore.ops.AllGather.html#mindspore.ops.AllGather" title="mindspore.ops.AllGather"><code class="xref py py-class docutils literal notranslate"><span class="pre">mindspore.ops.AllGather</span></code></a> 算子的重计算属性。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>仅支持 <cite>Graph</cite> 模式。</p></li>
<li><p>建议使用(cell.recompute(parallel_optimizer_comm_recompute=True/False)去配置由优化器并行生成的 <a class="reference internal" href="../ops/mindspore.ops.AllGather.html#mindspore.ops.AllGather" title="mindspore.ops.AllGather"><code class="xref py py-class docutils literal notranslate"><span class="pre">mindspore.ops.AllGather</span></code></a> 算子，而不是直接使用该接口。</p></li>
</ul>
</div>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.requires_grad">
<em class="property">property </em><code class="sig-name descname">requires_grad</code><a class="headerlink" href="#mindspore.Parameter.requires_grad" title="Permalink to this definition">¶</a></dt>
<dd><p>表示该参数是否需要求梯度进行更新。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.set_data">
<code class="sig-name descname">set_data</code><span class="sig-paren">(</span><em class="sig-param">data</em>, <em class="sig-param">slice_shape=False</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.Parameter.set_data" title="Permalink to this definition">¶</a></dt>
<dd><p>设置参数数据。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>data</strong> (Union[Tensor, int, float]) - 新数据。</p></li>
<li><p><strong>slice_shape</strong> (bool) - 如果 <cite>slice_shape</cite> 设为True，则不检查 <cite>data</cite> 和当前参数shape的一致性。默认值：False。</p></li>
</ul>
<p><strong>返回：</strong></p>
<p>完成数据设置的新参数。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.set_param_fl">
<code class="sig-name descname">set_param_fl</code><span class="sig-paren">(</span><em class="sig-param">push_to_server=False</em>, <em class="sig-param">pull_from_server=False</em>, <em class="sig-param">requires_aggr=True</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.Parameter.set_param_fl" title="Permalink to this definition">¶</a></dt>
<dd><p>设置参数和服务器的互动方式。</p>
<p><strong>参数：</strong></p>
<ul class="simple">
<li><p><strong>push_to_server</strong> (bool) - 表示是否将参数推送到服务器。默认值：False。</p></li>
<li><p><strong>pull_from_server</strong> (bool) - 表示是否应从服务器中拉取参数。默认值：False。</p></li>
<li><p><strong>requires_aggr</strong> (bool) - 表示是否应在服务器中聚合参数。默认值：True。</p></li>
</ul>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.set_param_ps">
<code class="sig-name descname">set_param_ps</code><span class="sig-paren">(</span><em class="sig-param">init_in_server=False</em><span class="sig-paren">)</span><a class="headerlink" href="#mindspore.Parameter.set_param_ps" title="Permalink to this definition">¶</a></dt>
<dd><p>表示可训练参数是否由参数服务器更新，以及可训练参数是否在服务器上初始化。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>仅当运行的任务处于参数服务器模式下有效。</p>
</div>
<p><strong>参数：</strong></p>
<p><strong>init_in_server</strong> (bool) - 表示参数服务器更新的可训练参数是否在服务器上初始化。默认值：False。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.sliced">
<em class="property">property </em><code class="sig-name descname">sliced</code><a class="headerlink" href="#mindspore.Parameter.sliced" title="Permalink to this definition">¶</a></dt>
<dd><p>获取参数的切片状态。</p>
</dd></dl>

<dl class="method">
<dt id="mindspore.Parameter.unique">
<em class="property">property </em><code class="sig-name descname">unique</code><a class="headerlink" href="#mindspore.Parameter.unique" title="Permalink to this definition">¶</a></dt>
<dd><p>表示参数是否唯一。</p>
</dd></dl>

</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="mindspore.ParameterTuple.html" class="btn btn-neutral float-right" title="mindspore.ParameterTuple" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="mindspore.SparseTensor.html" class="btn btn-neutral float-left" title="mindspore.SparseTensor" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2021, MindSpore.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>